TextView: render the background of border windows
authorPaolo Borelli <pborelli@gnome.org>
Sun, 15 Jun 2014 16:27:52 +0000 (18:27 +0200)
committerPaolo Borelli <pborelli@gnome.org>
Sun, 15 Jun 2014 16:57:06 +0000 (18:57 +0200)
Set the .top, .left, etc css classes and render the background
of the border windows.
Change the reftest implementation accordingly.

gtk/gtktextview.c
testsuite/reftests/textview-border-windows.c
testsuite/reftests/textview-border-windows.ui

index 4de4cd7cfacc7b1bb2b105df0fec346076082ba0..48c60b8fde6d29988125bb5f4ed6ec77b60fe478 100644 (file)
@@ -5326,6 +5326,38 @@ draw_text (cairo_t  *cr,
   gtk_text_view_paint (widget, cr);
 }
 
+static void
+paint_border_window (GtkTextView       *text_view,
+                     cairo_t           *cr,
+                     GtkTextWindowType  type,
+                     GtkStyleContext   *context,
+                     const char        *class)
+{
+  GdkWindow *window;
+
+  window = gtk_text_view_get_window (text_view, type);
+
+  if (window != NULL &&
+      gtk_cairo_should_draw_window (cr, window))
+    {
+      gint w, h;
+
+      gtk_style_context_save (context);
+      gtk_style_context_add_class (context, class);
+
+      w = gdk_window_get_width (window);
+      h = gdk_window_get_height (window);
+
+      gtk_cairo_transform_to_window (cr, GTK_WIDGET (text_view), window);
+
+      cairo_save (cr);
+      gtk_render_background (context, cr, 0, 0, w, h);
+      cairo_restore (cr);
+
+      gtk_style_context_restore (context);
+    }
+}
+
 static gboolean
 gtk_text_view_draw (GtkWidget *widget,
                     cairo_t   *cr)
@@ -5378,6 +5410,11 @@ gtk_text_view_draw (GtkWidget *widget,
       cairo_restore (cr);
     }
 
+  paint_border_window (GTK_TEXT_VIEW (widget), cr, GTK_TEXT_WINDOW_LEFT, context, GTK_STYLE_CLASS_LEFT);
+  paint_border_window (GTK_TEXT_VIEW (widget), cr, GTK_TEXT_WINDOW_RIGHT, context, GTK_STYLE_CLASS_RIGHT);
+  paint_border_window (GTK_TEXT_VIEW (widget), cr, GTK_TEXT_WINDOW_TOP, context, GTK_STYLE_CLASS_TOP);
+  paint_border_window (GTK_TEXT_VIEW (widget), cr, GTK_TEXT_WINDOW_BOTTOM, context, GTK_STYLE_CLASS_BOTTOM);
+
   /* Propagate exposes to all unanchored children. 
    * Anchored children are handled in gtk_text_view_paint(). 
    */
index 502b18b06d153bfd425db7a29be6338cf65f4b8d..019b654907d90e3f1bdbd73d23caa0ddf4c28838 100644 (file)
 
 #include <gtk/gtk.h>
 
-static void
-paint_border (GtkTextView       *text_view,
-              cairo_t           *cr,
-              GtkTextWindowType  type,
-              GtkStyleContext   *context,
-              const char        *class)
-{
-  GdkWindow *window;
-
-  window = gtk_text_view_get_window (text_view, type);
-
-  if (window != NULL &&
-      gtk_cairo_should_draw_window (cr, window))
-    {
-      gint w, h;
-
-      gtk_style_context_save (context);
-      gtk_style_context_add_class (context, class);
-
-      w = gdk_window_get_width (window);
-      h = gdk_window_get_height (window);
-
-      gtk_cairo_transform_to_window (cr, GTK_WIDGET (text_view), window);
-
-      cairo_save (cr);
-      gtk_render_background (context, cr, 0, 0, w, h);
-      cairo_restore (cr);
-
-      gtk_style_context_restore (context);
-    }
-}
-
-G_MODULE_EXPORT gboolean
-paint_border_windows (GtkTextView *text_view,
-                      cairo_t     *cr)
-{
-  GtkStyleContext *context;
-
-  context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
-
-  paint_border (text_view, cr, GTK_TEXT_WINDOW_LEFT, context, "left");
-  paint_border (text_view, cr, GTK_TEXT_WINDOW_RIGHT, context, "right");
-  paint_border (text_view, cr, GTK_TEXT_WINDOW_TOP, context, "top");
-  paint_border (text_view, cr, GTK_TEXT_WINDOW_BOTTOM, context, "bottom");
-
-  return FALSE;
-}
 
 G_MODULE_EXPORT void
 add_border_windows (GtkTextView *text_view)
index 7aa6b22fc6c90acec431df238a1ad5588798ba47..5ca2b2e078b3c5021f5e7305576fbcc5b1ecfedc 100644 (file)
@@ -13,7 +13,6 @@
         <property name="can_focus">True</property>
         <property name="wrap_mode">word</property>
         <signal name="map" handler="reftest:add_border_windows" swapped="no"/>
-        <signal name="draw" handler="reftest:paint_border_windows" swapped="no"/>
       </object>
     </child>
   </object>